<?php
function generateCouponCode($length = 10) {
	$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
	$ret = '';
	for($i = 0; $i < $length; ++$i) {
		$random = str_shuffle($chars);
		$ret .= $random[0];
	}
	return $ret;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="<?php echo base_url()?>css/reset.css" />
<link rel="stylesheet" href="<?php echo base_url()?>css/text.css" />
<link rel="stylesheet" href="<?php echo base_url()?>css/960_24_col.css" />
 <link rel="stylesheet" href="<?php echo base_url()?>css/jquery-ui-1.8.21.custom.css" />
 <link rel="stylesheet" href="<?php echo base_url()?>css/style.css" />
 <link rel="stylesheet" href="<?php echo base_url()?>css/faary.css" type="text/css" />
 <script type="text/javascript" src="<?php echo base_url()?>js/jquery-1.7.2.min.js"></script>
 <script type="text/javascript" src="<?php echo base_url()?>js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>js/scripts.js"></script>
 <script type="text/javascript" src="<?php echo base_url()?>js/jquery.validate.js"></script>
<script>
	$(function(){

		$(".date").datepicker({ dateFormat: "yy-mm-dd" });
		
		
		
});
	
</script>
	
ß

</head>

<body>
	<script type="text/javascript">
<!--
	function isEmailValid(email){
		var e = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		return e.test(email);
	}
	/*
	function sendForm(){
		
		
		jQuery("#imessageOK, #imessageERROR").hide();
		jQuery(".required").removeClass("required");
		if(jQuery("#TourName").val()==""){jQuery("#TourName").addClass("required");window.scroll(0,0);return false;}if(jQuery("#TourCode").val()==""){jQuery("#TourCode").addClass("required");window.scroll(0,0);return false;}if(jQuery("#Date").val()==""){jQuery("#Date").addClass("required");window.scroll(0,0);return false;}if(jQuery("#Description").val()==""){jQuery("#Description").addClass("required");window.scroll(0,0);return false;}jQuery("#SendaMessage").val("Please Wait...");		var AddDetails; AddDetails+="&TourName="+encodeURIComponent(jQuery("#TourName").val());AddDetails+="&TourCode="+encodeURIComponent(jQuery("#TourCode").val());AddDetails+="&Date="+encodeURIComponent(jQuery("#Date").val());AddDetails+="&Description="+encodeURIComponent(jQuery("#Description").val());		
		alert("Add sending function here...\n\nOr become FAARY member to download full package!")	}

*/
-->
</script>
	<div class="principal container_24">
		
		<!--logo-->
		<div class="logo grid_24">
			<div class="grid_1">&nbsp;</div>
			<div class="grid_4 logoimage"><img src="<?php echo base_url();?>img/logo.png" height="90"></div>
			<div class="logout grid_5"><a href="index.php?loginprocess/loginout"><img src="<?php echo base_url();?>img/bt_logout.jpg"/></a></div>
		</div><!-- end logo-->
		
		<!--menupricipal-->
		<div class="menuprincipal grid_24">
			<div class="menuprincipal grid_24">
			<a class="yearlist " href="index.php?ccoupon/listcoupon">Back to List </a>
		</div>
		</div>
		<!-- end menupricipal-->
				
			<div class="descprincipal grid_22">
				description
				<br/>
				<h3><?php // echo $message; ?></h3>
			</div>
			
			<div class="grid_24 listcontent">
				<h1>CREATE OR EDIT A TOUR</h1>
				<div class="grid_22 list">
<?php 
$flag=0;
if(isset($edit)!=true) {?>				
<form method="post" action="index.php?ccoupon/actioncreatecoupon"  class="iform grid_18 formtour" onSubmit="return true">
<?php }else{
$flag=1;
?>
<form method="post" action="index.php?ccoupon/actioneditcoupon"  class="iform grid_18 formtour" onSubmit="return true">
<input type="hidden" name="idcoupn"  value="<?php echo $couponinfo[0]["idcoupn"]; ?>" />
<?php }?>
<div id="imessageOK">Thank you! Message Sent!</div>
<div id="imessageERROR">ERROR: Message Not Sent!</div>
<ul class="">
<li class="iheader">CREATE a coupon</li>
<li><label for="TourName">*coupon Name</label><input class="itext" type="text" name="coupon[coupon_name]" id="coupon_name" value="<?php if($flag==1) echo $couponinfo[0]["coupon_name"]?>" /></li>
<li><label for="TourCode">*coupon Code</label><input class="itext" type="text" name="coupon[coupon_code]" id="coupon_code" value="<?php if($flag==1) {echo $couponinfo[0]["coupon_code"];}else{ echo generateCouponCode(8);}?>"/></li>
<li><label for="Description">*Description</label><textarea class="itextarea" name="coupon[coupon_desc]" id="coupon_desc" value=""><?php if($flag==1) echo $couponinfo[0]["coupon_desc"]?></textarea></li>
<li><label for="Date">*start</label><input class="itext date" type="text" name="coupon[coupon_start]" id="coupon_start"   value="<?php if($flag==1) echo $couponinfo[0]["coupon_start"] ?>"/></li>
<li><label for="Date">*end</label><input class="itext date" type="text" name="coupon[coupon_end]" id="coupon_end"     value="<?php if($flag==1) echo $couponinfo[0]["coupon_end"] ?>" /></li>
<li><label for="time">*coupon type</label>
<select class="iselect" type="select" name="coupon[coupon_type]" id="coupon_type">
	<option value="precent" <?php if(($flag==1)&&($couponinfo[0]['coupon_type']=="precent")){echo "selected"; } ?>>precentage</option>
	<option value="montant" <?php if(($flag==1)&&($couponinfo[0]['coupon_type']=="montant")){echo "selected"; } ?>>montant</option>
</select>
</li>
<li><label for="lieu">*montant ou %</label><input class="itext" type="text" name="coupon[coupon_reduce]" id="coupon_reduce"  value="<?php if($flag==1) echo $couponinfo[0]["coupon_reduce"]?>"/></li>
<li>
<input type="submit" name="submit" value="submit" />
</li>
</ul></form>
				</div>
			</div>
		
	</div><!--end principal-->
</body>
</html>